<!DOCTYPE >
<html lang="zh-cn">

	<head>
		<title>后台管理-举报</title>
		<% include ./partials/head %>
			<script type="text/javascript">
				var oReport = {
					type: 0,
					operator: function() {
						$("table").on('click', '.warn', function() {
							$this = $(this)
							if (window.confirm('你确定警告该用户么？')) {
								//认证 0警告，1封号
								$.post("/admin/report", {
									"reportId": $this.attr('reportId'),
									"userId": $this.attr('userId'),
									"reportType": 0,
									"content": $this.parent().prev().val()
								}, function(json) {
									if (json.code == 0) {
										alert(json.msg);
										$this.parents('tr').remove();
									} else {
										alert(json.msg);
									}
								}, 'json');
							} else {
								//取消
							}
						}).on('click', '.closeId', function() {
							$this = $(this)
							if (window.confirm('你确定要封禁该帐号么？')) {
								//封禁 
								$.post("/admin/report", {
									"reportId": $this.attr('reportId'),
									"userId": $this.attr('userId'),
									"reportType": 1
								}, function(json) {
									if (json.code == 0) {
										alert(json.msg);
										$this.parents('tr').remove();
									} else {
										alert(json.msg);
									}
								}, 'json');
							} else {
								//取消
							}
						}).on('click', '.forbiddenId', function() {
							$this = $(this)
							if (window.confirm('你确定要禁言该帐号么？')) {
								//禁言 
								$.post("/admin/report", {
									"reportId": $this.attr('reportId'),
									"userId": $this.attr('userId'),
									"reportType": 2
								}, function(json) {
									if (json.code == 0) {
										alert(json.msg);
										$this.parents('tr').remove();
									} else {
										alert(json.msg);
									}
								}, 'json');
							} else {
								//取消
							}
						}).on('click', '.pass', function() {
							$this = $(this)
							if (window.confirm('你确定要忽略？')) {
								//拒绝 
								$.post("/admin/report", {
									"reportId": $this.attr('reportId'),
									"userId": $this.attr('userId'),
									"reportType": 3
								}, function(json) {
									if (json.code == 0) {
										alert(json.msg);
										$this.parents('tr').remove();
									} else {
										alert(json.msg);
									}
								}, 'json');
							} else {
								//取消
							}
						}).on("click", ".contact", function() {
							$this = $(this)
							if (window.confirm('你确定要联系他么？')) {
								$.post("/admin/reportContact", {
									"userId": $this.attr('userId'),
									"content": $this.prev().val()
								}, function(json) {
									if (json.code == 0) {
										alert(json.msg);
									} else {
										alert(json.msg);
									}
								}, 'json');
							} else {
								//取消
							}
						}).on("click", ".cancleScreen", function() {
							$this = $(this)
							if (window.confirm('你确定要取消该话题的屏蔽么？')) {
								//拒绝 
								$.post("/admin/report/cancleScreen", {
									"circleId": $this.attr('circleId')
								}, function(json) {
									if (json.code == 0) {
										alert(json.msg);
									} else {
										alert(json.msg);
									}
								}, 'json');
							} else {
								//取消
							}
						}).on("click", ".neverScreen", function() {
							$this = $(this)
							if (window.confirm('你确定要将该话题设置为永不屏蔽么么？')) {
								//拒绝 
								$.post("/admin/report/neverScreen", {
									"circleId": $this.attr('circleId')
								}, function(json) {
									if (json.code == 0) {
										alert(json.msg);
									} else {
										alert(json.msg);
									}
								}, 'json');
							} else {
								//取消
							}
						})
					},
					change: function() {
						var state = window.location.href.split("=")[2];
						if (state == 1) {
							$("#report-filter").val("已处理");
						} else if (state == 2) {
							$("#report-filter").val("已忽略");
						} else {
							$("#report-filter").val("未处理");
						}
						$("#report-filter").on("change", function() {
							var value = $(this).children('option:selected').val();
							window.location.href = window.location.origin + "/admin/report?type=" + oReport.type + "&status=" + value;
						})
					},
					init: function() {
						this.operator();
						this.change();
					}
				}
				$(document).ready(function() {
//					if (window.location.href.split("=").length == 2) {
//						var type = window.location.href.split("=")[1];
//					} else {
//						var type = window.location.href.split("=")[1].split("&")[0];
//					}
//					oReport.type = type;
					oReport.init();
				})
			</script>
	</head>

	<body>
		<header>
			<!-- Preloader -->
			<div id="preloader">
				<div id="status">&nbsp;</div>
			</div>
		</header>
		<div class="ch-container">

			<!-- 首页内容 -->
			<div class="wrap-fluid">
				<div class="container-fluid paper-wrap bevel tlbr">

					<!-- CONTENT -->
					<!--TITLE -->

					<!--/ TITLE -->

					<!-- BREADCRUMB -->
					<ul id="breadcrumb">
						<li>
							<span class="entypo-home"></span>
						</li>
						<li><i class="fa fa-lg fa-angle-right"></i>
						</li>
						<li><a href="#" title="举报管理">举报管理</a>
						</li>
					</ul>

					<!--测试数据-->
					<div class="content-wrap">
						<div class="row">
							<div class="col-sm-12">
								<div class="nest" id="FootableClose">
									<div class="title-alt">
										<h6>举报管理</h6>
										<div class="titleClose">
											<a class="gone" href="#FootableClose">
												<span class="entypo-cancel"></span>
											</a>
										</div>
										<div class="titleToggle">
											<a class="nav-toggle-alt" href="#Footable">
												<span class="entypo-up-open"></span>
											</a>
										</div>

									</div>
									<div class="body-nest" id="Filtering">

										<div class="row" style="margin-bottom:10px;">
											<div class="col-sm-4">
												<input class="form-control" id="filter" placeholder="Search..." type="text">
											</div>
											<div class="col-sm-2">
												<select id="report-filter" class="filter-status form-control">
													<option>全部</option>
													<option value="0">未处理</option>
													<option value="2">已忽略</option>
													<option value="1">已处理</option>
												</select>
											</div>
											<!--<div class="col-sm-2">
													<select class="filter-num form-control">
														<option value="1">每页10个
															<option value="2">每页50个
																<option value="3">每页100个
													</select>
												</div>-->
											<div class="col-sm-6">

												<a href="#clear" style="margin-left:10px;" class="pull-right btn btn-info clear-filter" title="clear filter">重置</a>
											</div>

										</div>
										<table class="table-striped footable-res footable metro-blue data-table" data-page-size="30" data-filter="#filter" data-filter-text-only="true">
											<thead>
												<tr>
													<th data-toggle="true"></th>
													<th>被举报人</th>
													<th>被举报人ID</th>
													<th>举报原因</th>
													<th>截图</th>
													<th>被举报次数</th>
													<th>处理状况</th>
													<th data-hide="phone,tablet" data-sort-initial="descending">举报时间</th>
													<th data-hide="phone,tablet">举报人</th>
													<th data-hide="phone,tablet">举报人ID</th>
												</tr>
											</thead>
											<tbody>
												<% if (typeof report != "undefined") { %>
													<% report.forEach(function(report,index) { %>
														<tr>
															<td class="center">
																<%=index%>
															</td>

															<td class="center">
																<a href="/admin/userinfo?userId=<%= report.get('reportee').id%>">
																	<%= report.get("reportee").get("nickname") %>
																</a>
															</td>
															<td class="center">
																<%= report.get('reportee').get("molianId") %>
															</td>
															<td class="center">
																<%= report.get("remark") %>
															</td>
															<td class="center">
																<% if (typeof report.get('img') != "undefined") { %>
																	<a href="<%=report.get('img').url()%>" target="_blank"> <img style="max-height:100px" src="<%=report.get('img').url()%>"></a>
																	<% } %>
															</td>
															<td class="center">
																<%=report.get("reportee").get("reportCount")%>
															</td>

															<td class="center">
																<% if(report.get("status")==1){ %>
																	<span class="btn">已处理</span>
																	<% } %>
																		<% if(report.get("status")==2){ %>
																			<span class="btn">已忽略</span>
																			<% } %>
																				<% if(report.get("status")==0){ %>
																					<input class="warnContent" type="text" placeholder="警告内容">
																					<p>
																						<span class="btn btn-success warn " reportId=<%=report.id%> userId=<%=report.get('reportee').id%>>警告</span>
																						<span class="btn btn-danger closeId" reportId=<%=report.id%> userId=<%=report.get('reportee').id%>>封号</span>
																						<span class="btn btn-danger forbiddenId" reportId=<%=report.id%> userId=<%=report.get('reportee').id%>>禁言</span>
																						<span class="btn btn-info pass" reportId=<%=report.id%> userId=<%=report.get('reportee').id%>>忽略</span>
																					</p>

																					<% } %>

															</td>
															<td class="center">
																<%=Format(new Date(report.createdAt))%>
															</td>
															<td class="center">
																<a href="/admin/userinfo?userId=<%= report.get('reporter').id%>">
																	<%= report.get("reporter").get("nickname") %>
																</a>
																<p>
																	<input class="contactContent" type="text" placeholder="联系他">
																	<span class="btn btn-success contact " userId=<%=report.get( 'reporter').id%>>
	                             联系他
	                          	</span></p>
															</td>
															<td class="center">
																<%= report.get('reporter').get("molianId") %>
															</td>
														</tr>
														<% }) %>
															<% } %>
											</tbody>
											<tfoot>
												<tr>
													<td colspan="5">
														<div class="pagination pagination-centered"></div>
													</td>
												</tr>
											</tfoot>
										</table>
									</div>
								</div>
							</div>
						</div>
					</div>
					<!-- END OF BREADCRUMB -->

					<!-- /END OF CONTENT -->

					<!-- FOOTER -->
					<div class="footer-space"></div>
					<div id="footer">
						<div class="devider-footer-left"></div>
						<div class="time">
							<p id="spanDate">
								<p id="clock">
						</div>
						<div class="copyright">Made by HT
							<span class="entypo-heart"></span>广州聚脉互联网络服务有限公司</div>
						<div class="devider-footer"></div>

					</div>
					<!-- / END OF FOOTER -->

				</div>
			</div>

		</div>
		<% include ./partials/external %>

			<script src="/assets/js/button/ladda/spin.min.js"></script>

			<script src="/assets/js/button/ladda/ladda.min.js"></script>

			<script src="/assets/js/footable/js/footable.filter.js"></script>

			<script type="text/javascript">
				$(function() {
					$('.footable-res').footable();
				});
			</script>
	</body>

</html>